package com.example.guiguiapplicatio;

import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.NavigationUI;

import com.google.android.material.bottomnavigation.BottomNavigationView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // 获取页面上的底部导航栏控件
        BottomNavigationView navView = findViewById(R.id.nav_view);

        // 配置navigation与底部菜单之间的联系
        // 底部菜单的样式里面的item里面的ID与navigation布局里面指定的ID必须相同，否则会出现绑定失败的情况
//        AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
//                R.id.navigation_home,R.id.navigation_edit,R.id.navigation_user,R.id.navigation_view)
//                .build();
        // 建立fragment容器的控制器，这个容器就是页面的上的fragment容器
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);

        // 启动
//        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
        NavigationUI.setupWithNavController(navView, navController);
        DisplayMetrics dm = getResources().getDisplayMetrics();
//手机宽度dp值 = 手机实际宽度像素px / 手机屏幕密度比
        float widthDP = dm.widthPixels / dm.density;
// dm.heightPixels 表示手机实际高度像素px
        float heightDP = dm.heightPixels / dm.density;
        Log.d("MainActivity", "手机屏幕宽度/dp是: "+widthDP);
        Log.d("MainActivity", "手机实际宽度像素dp是: "+dm.widthPixels);
        Log.d("MainActivity", "手机屏幕密度比是: "+dm.density);
        Log.d("MainActivity", "手机屏幕显示dpi是: "+dm.densityDpi);





    }


}